package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysPositionsPlan;
import com.ruoyi.system.service.ISysPositionsPlanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 招聘计划信息Controller
 * 
 * @author ruoyi
 * @date 2025-07-16
 */
@RestController
@RequestMapping("/system/plan")
public class SysPositionsPlanController extends BaseController
{
    @Autowired
    private ISysPositionsPlanService sysPositionsPlanService;

    /**
     * 查询招聘计划信息列表
     */
//    @PreAuthorize("@ss.hasPermi('system:plan:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysPositionsPlan sysPositionsPlan)
    {
        startPage();
        List<SysPositionsPlan> list = sysPositionsPlanService.selectSysPositionsPlanList(sysPositionsPlan);
        return getDataTable(list);
    }

    /**
     * 导出招聘计划信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:plan:export')")
    @Log(title = "招聘计划信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysPositionsPlan sysPositionsPlan)
    {
        List<SysPositionsPlan> list = sysPositionsPlanService.selectSysPositionsPlanList(sysPositionsPlan);
        ExcelUtil<SysPositionsPlan> util = new ExcelUtil<SysPositionsPlan>(SysPositionsPlan.class);
        util.exportExcel(response, list, "招聘计划信息数据");
    }

    /**
     * 获取招聘计划信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:plan:query')")
    @GetMapping(value = "/{planId}")
    public AjaxResult getInfo(@PathVariable("planId") Long planId)
    {
        return success(sysPositionsPlanService.selectSysPositionsPlanByPlanId(planId));
    }

    /**
     * 新增招聘计划信息
     */
    @PreAuthorize("@ss.hasPermi('system:plan:add')")
    @Log(title = "招聘计划信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysPositionsPlan sysPositionsPlan)
    {
        return toAjax(sysPositionsPlanService.insertSysPositionsPlan(sysPositionsPlan));
    }

    /**
     * 修改招聘计划信息
     */
    @PreAuthorize("@ss.hasPermi('system:plan:edit')")
    @Log(title = "招聘计划信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysPositionsPlan sysPositionsPlan)
    {
        return toAjax(sysPositionsPlanService.updateSysPositionsPlan(sysPositionsPlan));
    }

    /**
     * 删除招聘计划信息
     */
    @PreAuthorize("@ss.hasPermi('system:plan:remove')")
    @Log(title = "招聘计划信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{planIds}")
    public AjaxResult remove(@PathVariable Long[] planIds)
    {
        return toAjax(sysPositionsPlanService.deleteSysPositionsPlanByPlanIds(planIds));
    }
}
